package com.YxyBackMange.StatcManger;

import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
 * Created by Administrator on 2017/4/19.
 */
public class StaticConfig {
    private String name;//此时静态化名称
    private UrlPar generateUrl;//静态页面地址
    private List<UrlPar> refreshUrls = new ArrayList<UrlPar>(); //刷新页面地址
    private long interVal = 0;//定时刷新时间
    private String prefix = ""; //前缀
    private String suffix = ".shtml";//文件名后缀
    private List<String> values;

    public String getFilePath() {
        String valueStr = "";
        for (String s : values) {
            valueStr += s;
        }
        return File.separatorChar + prefix + valueStr + suffix;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public UrlPar getGenerateUrl() {
        return generateUrl;
    }

    public void setGenerateUrl(UrlPar generateUrl) {
        this.generateUrl = generateUrl;
    }

    public List<UrlPar> getRefreshUrls() {
        return refreshUrls;
    }

    public void setRefreshUrls(List<UrlPar> refreshUrls) {
        this.refreshUrls = refreshUrls;
    }

    public long getInterVal() {
        return interVal;
    }

    public void setInterVal(long interVal) {
        this.interVal = interVal;
    }




    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public List<String> getValues() {
        return values;
    }

    public void setValues(List<String> values) {
        this.values = values;
    }

    @Override
    public String toString() {
        return "StaticConfig{" +
                "name='" + name + '\'' +
                ", generateUrl=" + generateUrl +
                ", refreshUrls=" + refreshUrls +
                ", interVal=" + interVal +
                ", prefix='" + prefix + '\'' +
                ", suffix='" + suffix + '\'' +
                ", values=" + values +
                '}';
    }
}

class UrlPar {
    private String url;
    private Set<String> pars = new HashSet<String>();
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Set<String> getPars() {
        return pars;
    }

    public void setPars(Set<String> pars) {
        this.pars = pars;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UrlPar urlPar = (UrlPar) o;
        return url != null ? url.equals(urlPar.url) : urlPar.url == null;
    }

    @Override
    public int hashCode() {
        return url != null ? url.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "UrlPar{" +
                "url='" + url + '\'' +
                ", pars=" + pars +
                '}';
    }
}
